package com.polaris.live.adapter.vip

import com.blankj.utilcode.util.StringUtils
import com.blankj.utilcode.util.TimeUtils
import com.bumptech.glide.Glide
import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.databinding.AdapterVipDetailBinding
import com.polaris.live.resp.back_resp.UserVipDetailResp
import com.polaris.live.translation.R.string
import com.polaris.live.utils.CommonUtils.toBoolean
import com.polaris.live.utils.image.ImageUtils

/**
 * VipDetailAdapter
 *
 * @author Created by 天晴 on 2024/12/17/026 16:57
 */
class VipDetailAdapter : BaseBindingAdapter<AdapterVipDetailBinding, UserVipDetailResp>() {

    override fun convert(holder: VBViewHolder<AdapterVipDetailBinding>, item: UserVipDetailResp) {
        holder.vb.apply {
            Glide.with(context)
                .load(ImageUtils.imgPath(item.icon))
                .into(levelImg)
            val vipLevelText = StringUtils.getString(string.vip_level, item.level)
            val vipCardText = if (item.trial.toBoolean()) "(${StringUtils.getString(string.experience_card)})" else ""
            messageTv.text = vipLevelText + vipCardText
            sourceTv.text = item.sourceText
            timeTv.text = TimeUtils.millis2String(item.createTime.toLong(), "yyyy.MM.dd HH:mm:ss")
            daysTv.text = StringUtils.getString(string.vip_details_add_days, item.days)
        }
    }

}
